<?php

function retrieve_perjanjian_data(&$data, $kode, $id_po = "") {
    $CI = &get_instance();
    $kode = $CI->security->xss_clean($kode);
    $result = $CI->model_transaksi_penyewaan_tc->getPerjanjianData("WHERE i.id_perjanjian = '". mysql_escape_string($kode)."'");
    $row = $result->row();

    $data["id_perjanjian"] = $row->id_perjanjian;
    $data["nomor_perjanjian"] = $row->nomor_perjanjian;
    $data["tanggal_perjanjian"] = $row->tanggal_perjanjian;
    $data["using_dollar_currency"] = $row->using_dollar_currency;
    $data["approved_by"] = $row->approved_by;
    $data["tambahkan_ppn"] = $row->tambahkan_ppn;
    $data["penerbit_perjanjian"] = $row->penerbit_perjanjian;
    $data["diskon"] = $row->diskon;
    $data["id_bank"] = $row->id_bank;
    $data["id_customer"] = $row->id_customer;
    $data["nama_customer"] = $row->nama_customer;
    $data["telepon_customer"] = $row->telepon_customer;
    $data["alamat_customer"] = $row->alamat_customer;
    $data["fax_customer"] = $row->fax_customer;
    $data["submitter"] = $row->submitter;
    $data["date_submit"] = $row->date_submit;
    $data["ppn"] = $row->ppn;
    $data["cabang"] = $row->cabang;
    $data["nomor_rekening"] = $row->nomor_rekening;
    $data["nama_bank"] = $row->nama_bank;
    $data["alamat_detail_customer"] = $row->alamat_detail_customer;
    $data["alamat_komplit"] = $row->alamat_customer."\n".$row->kota_customer."\n".$row->kode_pos_customer;
    $data["kontak_komplit"] = $row->telepon_customer."/".$row->fax_customer."/".$row->email_customer;

    $data["nama_jenis_kapal"]= $row->nama_jenis_kapal;
    $data["jangka_waktu_sewa"]= $row->jangka_waktu_sewa;
    $data["delivery_dan_redelivery"]= $row->delivery_dan_redelivery;
    $data["harga_sewa"]= $row->harga_sewa;
    $data["cara_pembayaran"]= $row->cara_pembayaran;
    $data["kewajiban_pemilik"]= $row->kewajiban_pemilik;
    $data["kewajiban_penyewa"]= $row->kewajiban_penyewa;
    $data["daerah_operasional_kapal"]= $row->daerah_operasional_kapal;
    $data["force_majeure"]= $row->force_majeure;
    $data["perselisihan"]= $row->perselisihan;
    $data["submitter"]= $row->submitter;
    $data["using_dollar_currency"]= $row->using_dollar_currency;
    $data["tambahkan_ppn"]= $row->tambahkan_ppn;
    $data["diskon"]= $row->diskon;

    $data["use_header"] = $CI->model_transaksi_penyewaan_tc->get_scalar("SELECT tampilkan_header FROM master_setting_laporan WHERE nama_laporan = 'SURAT_PERJANJIAN_TC'", "tampilkan_header");
    
}



function retrieve_invoice_data(&$data, $kode, $id_po = "") {
    
    $CI = &get_instance();
    $kode = $CI->security->xss_clean($kode);
    $result = $CI->model_transaksi_penyewaan_invoice->getInvoiceDataTC("WHERE i.id_invoice = '". mysql_escape_string($kode)."'");
    $row = $result->row();
    
    $data["id_invoice"] = $row->id_invoice;
    $data["tanggal_invoice"] = $row->tanggal_invoice;
    $data["nomor_invoice"] = $row->nomor_invoice;
    $data["id_perjanjian"] = $row->id_po;
    $data["crc"] = $row->using_dollar_currency;
    $data["penerbit_invoice"] = $row->penerbit_invoice;
    $data["diskon_iv"] = $row->diskon ? $row->diskon : 0;
    $data["item_iv"] = $CI->model_transaksi_penyewaan_invoice->getInvoiceItem($data["id_invoice"]);
    $data["bank"] = $CI->model_transaksi_penyewaan_invoice->getInvoiceBank($data["crc"]);
    
    if ($id_po == ""){
        $id_po = $row->id_perjanjian;
    }
    retrieve_perjanjian_data($data, $id_po);
    $data["using_dollar_currency"] = $row->using_dollar_currency;
    $data["tambahkan_ppn"] = $row->tambahkan_ppn;
    $data["item"] = $data["item_iv"];
    $data["use_header"] = $CI->model_transaksi_penyewaan_invoice->get_scalar("SELECT tampilkan_header FROM master_setting_laporan WHERE nama_laporan = 'INVOICE_KE_PELANGGAN'", "tampilkan_header");
}
?>
